﻿/* 关于 IB, 您可以参考 http://blog.sina.com.cn/s/blog_604c436d0100o5j0.html.
 * IB 是项目 zsharedcode 的一部分, 您可以参考 http://code.google.com/p/zsharedcode/ 或者 http://blog.sina.com.cn/s/blog_604c436d0100o04s.html.
 * Visual Studio 2010 项目模板请访问 http://blog.sina.com.cn/s/blog_604c436d0100o8gn.html.
 * 所有项目源码托管地址: http://panzer.codeplex.com/.
 * */
#define USELOCALSETTING

using System;
using System.Collections.Generic;
using System.Windows.Forms;

// HACK: 如运行有偏差，代码中的 jQuery 可能需要依据最新的 blog 页面， IE 或者 jQuery 版本调整。或者注释掉 #define USELOCALSETTING，采用网络设置中的 jQuery。

namespace IBBloggerTemplate
{

	static class Program
	{
	
		// 存放 jQuery 和页面地址等设置。
		private static readonly SortedList<string, string> settings = new SortedList<string, string> ( );

		// 由其它类访问 jQuery 和页面地址等设置。
		public static SortedList<string, string> Settings
		{
			get { return settings; }
		}

		/// <summary>
		/// 应用程序的主入口点。
		/// </summary>
		[STAThread]
		static void Main ( )
		{
			Application.EnableVisualStyles ( );
			Application.SetCompatibleTextRenderingDefault ( false );

#if USELOCALSETTING
			// 使用本地代码设置。
			settings.Add ( "SinaUserNameTagJQuery", "'#login_name_d'" );
			settings.Add ( "SinaPasswordTagJQuery", "'#login_pass_d'" );
			settings.Add ( "SinaTestIsLoginTagJQuery", "'#linkTrayLogin'" );
			settings.Add ( "SinaTestIsLoginTagJS", "document.getElementById('linkTrayLogin')" );
			settings.Add ( "SinaLoginTagJS", "document.getElementById('login_button')" );
			settings.Add ( "SinaEditBlogPage", "http://control.blog.sina.com.cn/admin/article/article_add.php" );
			settings.Add ( "SinaTitleTagJQuery", "'#articleTitle'" );
			settings.Add ( "SinaTextTagJQuery", "'#SinaEditorTextarea'" );
			settings.Add ( "SinaCatalogTagJS", "$('#componentSelect').val($('option:contains({0})').attr('value'))" );
			settings.Add ( "SinaTagTagJQuery", "'#articleTagInput'" );
			settings.Add ( "SinaPublicTagJS", "document.getElementById('articlePostBtn')" );
			settings.Add ( "SinaShiftEditModeTagJQuery", "'#SinaEditor_59_viewcodecheckbox'" );

			settings.Add ( "163UserNameTagJQuery", "'.ztxt:text'" );
			settings.Add ( "163PasswordTagJQuery", "'.zwd:password'" );
			settings.Add ( "163TestIsLoginTagJQuery", "'a:contains(登录)'" );
			settings.Add ( "163LoginTagJQuery", "'.wbtn:button'" );
			settings.Add ( "163TitleTagJQuery", "'.ztag:text'" );
			settings.Add ( "163TextTagJQuery", "'textarea.ztag'" );
			settings.Add ( "163CatalogTagJS", "$('[name=cls]').val($('option:contains({0})').attr('value'))" );
			settings.Add ( "163TagTagJQuery", "'[name=tag]:text'" );
			settings.Add ( "163PublicTagJQuery", "'[value=发表日志]:button'" );
			settings.Add ( "163ShiftEditModeTagJQuery", "'#ne-auto-id-source'" );
#else
			#region " 使用远程设置。 "
			try
			{
				// 获取 http://zoyobar.googlecode.com/files/IBBloggerTemplate.2.2.setting.xml 中包含的设置。
				XmlDocument xml = new XmlDocument ( );
				xml.Load ( "http://zoyobar.googlecode.com/files/IBBloggerTemplate.2.2.setting.xml " );

				// 这里省去了检查设置。
				foreach ( XmlNode node in xml.SelectNodes ( "//setting" ) )
					settings.Add ( node.Attributes["name"].Value, node.Attributes["value"].Value );

			}
			catch { }
			#endregion
#endif

			Application.Run ( new FormTemplate ( ) );
		}

	}

}
